﻿@model Himall.Web.Areas.Mobile.Models.VshopCouponInfoModel
@{
    ViewBag.Title = Model.CouponData.CouponName + " 优惠券";
}
@if (Model.IsShowSyncWeiXin)
{
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        wx.config({
            debug: false,
            appId: '@(Model.WXJSInfo.appid)',
            timestamp: @(Model.WXJSInfo.timestamp),
            nonceStr: '@(Model.WXJSInfo.nonceStr)',
            signature: '@(Model.WXJSInfo.signature)',
            jsApiList: [
              'addCard'
            ]
        });
    </script>
}
<div class="container">
    <div class="coupon">
        <div class="logo00"><a href=""><img class="logo" src="@ViewBag.ShopLogo" /></a></div>
        <div class="coupon-view success">
            <p>￥@Model.CouponData.Price.ToString("f2")</p>
            <h3>领取成功</h3>
            <span></span>
        </div>
        <div class="coupon-info">
            <p class="time"><i></i>有效日期：@Model.CouponData.StartTime.ToString("yyyy-MM-dd") 至 @Model.CouponData.EndTime.ToString("yyyy-MM-dd")</p>
            <p>使用限制：订单满<span>@Model.CouponData.OrderAmount.ToString("f2")元</span>可使用<span>（不含运费）</span></p>
        </div>
        @if (Model.IsShowSyncWeiXin)
        {
            <div class="coupon-btn" id="addCard" style="display:none;"><a class="btn btn-block btn-lg" href="#">同步到微信卡包</a></div>
        }
        <div class="coupon-btn"><a class="btn btn-block btn-lg" href="@Url.Action("home", "shop", new { area="web",id=Model.ShopId})">立即使用</a></div>
    </div>
    @{Html.RenderPartial("~/Areas/Mobile/Templates/Default/Views/Shared/_4ButtonsFoot_fav.cshtml");}
</div>
@if (Model.IsShowSyncWeiXin)
{
    <script src="~/Scripts/jquery.json.js"></script>
    <script type="text/javascript">
    $(function(){
        loadingobj=showLoading("数据装载中...");
        var geturl= '/' + areaName + '/vshop/GetWXCardData/';
        $.post(geturl,{id:'@(Model.CouponRecordId)'}, function (data,status) {
            loadingobj.close();
            if(data.cardId){
                if(data.cardId!="0"){
                    $("#addCard").show();
                    $('#addCard').click(function () {
                        wx.addCard({
                            cardList: [{
                                cardId: data.cardId,
                                cardExt: jQuery.toJSON(data.cardExt)
                            }],
                            success: function (res) {
                                $("#addCard").hide();
                            }
                        });
                    });
                }
            }
        });
    });
    </script>

}

